import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../utils/app_color.dart';
import '../../../utils/ly_medal_manager.dart';

class LYMedalBuyResultPage extends StatefulWidget {
  final LYMedalType type;

  const LYMedalBuyResultPage({super.key, required this.type});

  @override
  State<LYMedalBuyResultPage> createState() => _LYMedalBuyResultPageState();
}

class _LYMedalBuyResultPageState extends State<LYMedalBuyResultPage> {
  void _sureButtonDidClick() {
    Get.close(0);
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        _makeContentWidget(),
      ],
    );
  }

  Widget _makeContentWidget() {
    return Container(
      margin: const EdgeInsets.only(left: 30, right: 30),
      decoration: const BoxDecoration(
          image: DecorationImage(
        image: AssetImage('assets/images/medal_buy_result_bg_img.png'),
        fit: BoxFit.fill,
      )),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: [
          Container(
              alignment: Alignment.center,
              padding: const EdgeInsets.only(top: 45),
              child: Image.asset(
                'assets/images/${_imageName()}',
                width: 80,
                height: 80,
              )),
          Container(
            alignment: Alignment.center,
            padding: const EdgeInsets.only(top: 17, left: 28, right: 28),
            child: const Text(
              'You have successfully unlocked the advanced badge.',
              maxLines: 2,
              textAlign: TextAlign.center,
              style: TextStyle(
                  fontSize: 14,
                  fontWeight: FontWeight.bold,
                  color: AppColors.color404040),
            ),
          ),
          Container(
            width: double.infinity,
            margin: const EdgeInsets.only(bottom: 40, top: 32),
            alignment: Alignment.center,
            child: InkWell(
              onTap: () => _sureButtonDidClick(),
              child: Container(
                width: 117,
                height: 38,
                alignment: Alignment.center,
                decoration: const BoxDecoration(
                    image: DecorationImage(
                        image: AssetImage('assets/images/buy_btn_bg_icon.png'),
                        fit: BoxFit.cover)),
                child: const Text(
                  'OK',
                  style: TextStyle(
                      fontWeight: FontWeight.bold,
                      color: AppColors.color202020,
                      fontSize: 14),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }

  String _imageName() {
    if (widget.type == LYMedalType.germination) {
      return "onset_oath _badge_right.png";
    } else if (widget.type == LYMedalType.seedlingStage) {
      return "steadfast_streak_crest_r.png";
    } else if (widget.type == LYMedalType.saplingStage) {
      return "persistent_pledge_medallion_r.png";
    }
    return "triumphant_commitment_emblem_r.png";
  }
}
